package com.hue.springbootneo4j.controller;

import com.hue.springbootneo4j.entity.StarRelationShip;
import com.hue.springbootneo4j.service.StarRelationShipService;
import com.hue.springbootneo4j.service.StarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/star")
@CrossOrigin
public class StarController {
    @Autowired
    private StarService starService;
    @Autowired
    private StarRelationShipService starRelationShipService;

    @GetMapping("/all")
    public Map<String, Object> all() {
        Map<String, Object> map = new HashMap<>();
        map.put("nodes", starService.all());
        map.put("edges", starRelationShipService.all());
        return map;
    }

    @GetMapping("/byName/{name}")
    public Map<String, Object> byName(@PathVariable("name") String name) {
        return starService.byName(name);
    }
}
